package com.itheima.d2_lambda;

public class LambdaTest1 {
    public static void main(String[] args) {
        // 目标：认识Lambda表达式.
        Swimming s1 = new Swimming() {
            @Override
            public void swim() {
                System.out.println("孙杨在游泳！！");
            }
        };

        Swimming s2 = ()->{
            //方法体，重写
            System.out.println("孙杨杨在在游泳");
        };


        s1.swim();
        s2.swim();

        // 注意：Lambda表达式并不是说能简化全部匿名内部类的写法，只能简化函数式接口的匿名内部类。
       /* Animal a = ()->{

        };*/
    }
}

@FunctionalInterface
interface Swimming {
    void swim();
}

abstract class Animal {
    public abstract void run();
}

class SunYang implements Swimming {

    @Override
    public void swim() {

    }
}